package demo;
//volatile关键字
import java.util.Scanner;

public class Test7 {
    public volatile static int flag = 0;

    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread(()->{
           while (flag == 0){

           }
            System.out.println("1");
        });
        Thread thread1 = new Thread(()->{
            Scanner scanner = new Scanner(System.in);
            flag = scanner.nextInt();
        });
        thread.start();
        thread1.start();
        thread.join();
        thread1.join();

    }
}
